
import Vue from 'vue';
import Router from 'vue-router';
import xxx from '@/view/xxx/xxx.vue';

Vue.use(Router);

const routes = [
  {
    name: '/',
    path: '/',
    components: { xxx },
  },
];

const router = new Router({ routes });

// 路由守卫，验证登录
router.beforeEach((to, from, next) => {
  const token = 1; // 在这里获取 token
  if (to.path === "/") { // 这里假设登录页面路由是 /
    next();
  } else {
    token ? next() : next("/");
  }
});

export default router;
